package com.ywqf_api.controller;

import com.ywqf_api.dto.exc.ReturnExcution;
import com.ywqf_api.dto.in.HouseKeepDto;
import com.ywqf_api.dto.in.WaterFeeDto;
import com.ywqf_api.entity.Commodity;
import com.ywqf_api.enums.ReturnEnum;
import com.ywqf_api.service.HouseKeepService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/4/8 0008.
 */
@Api(description="houseKeep接口",produces="application/json")
@Controller
@RequestMapping("houseKeep")
public class HouseKeepController {
    @Autowired
    private HouseKeepService houseKeepService;


    /**
     * 查询家政服务
     * @param communityId
     * @return
     */
    @ApiOperation(value = "查询家政服务", httpMethod = "POST", notes = "查询家政服务")
    @RequestMapping(value = "findHouseKeep",method = RequestMethod.POST)
    @ResponseBody
    public ReturnExcution findHouseKeep (Integer communityId,Integer type){
          List<Commodity> list = houseKeepService.findHouseKeep(communityId,type);
          if(list == null){
              return new ReturnExcution(ReturnEnum.FIND_KEEP_NULL,null);
          }
        return new ReturnExcution(ReturnEnum.FIND_SUCCESS,list);
    }

    /**
     * 查询此家政服务的轮播图和数据
     * @param goodsId
     * @return
     */
    @ApiOperation(value = "查询此家政服务的轮播图和数据", httpMethod = "POST", notes = "查询此家政服务的轮播图和数据")
    @RequestMapping(value = "findHouseKeepData",method = RequestMethod.POST)
    @ResponseBody
    public ReturnExcution findHouseKeepData (Integer goodsId){
        Map map = houseKeepService.findHouseKeepData(goodsId);
        if(map == null){
            return new ReturnExcution(ReturnEnum.FIND_KEEP_ONE_NULL,null);
        }
        return new ReturnExcution(ReturnEnum.FIND_SUCCESS,map);
    }

    /**
     * 添加家政订单
     * @param houseKeepDto
     * @return
     */
    @ApiOperation(value = "添加家政订单", httpMethod = "POST", notes = "添加家政订单")
    @RequestMapping(value = "saveHouseKeep",method = RequestMethod.POST)
    @ResponseBody
    public ReturnExcution saveHouseKeep (HouseKeepDto houseKeepDto){
        int save = houseKeepService.saveHouseKeep(houseKeepDto);
        return new ReturnExcution(ReturnEnum.ADD_SUCCESS,save);
    }

    /**
     * 添加次卡
     * @param houseKeepDto
     * @return
     */
    @ApiOperation(value = "添加次卡", httpMethod = "POST", notes = "添加家政订单")
    @RequestMapping(value = "saveHouseKeepCard",method = RequestMethod.POST)
    @ResponseBody
    public ReturnExcution saveHouseKeepCard (HouseKeepDto houseKeepDto){
        int save = houseKeepService.saveHouseKeepCard(houseKeepDto);
        return new ReturnExcution(ReturnEnum.ADD_SUCCESS,save);
    }

}
